/**
 * Created by zhang on 14-10-31.
 */

var xmlHttp;

function createXMLHttpRequest(){
    if(window.XMLHttpRequest){
        xmlHttp = new XMLHttpRequest();
    }else if(window.ActiveXObject){
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
}
createXMLHttpRequest();

function changeTime(){
    var url = "check.php?time="+new Date().getTime();
    xmlHttp.onreadystatechange = function(){
        if(xmlHttp.readyState = 4){
            var time = xmlHttp.responseText;
            document.getElementsByTagName('div')['0'].innerHTML = time;
        }
    }
    xmlHttp.open('get',url,false);
    xmlHttp.send(null);
}
setInterval("changeTime()",1000);